<?php
class ExaminfoAction extends CommonAction {
    function _filter(&$map){
        //$map['id'] = array('egt',1);
        //$map['wymc'] = array('like',"%".$_POST['wymc']."%");
    }
    function edit() {
        $model  = M("Examinfo");
        $id     = I("id");
        $vo     = $model->getById($id);
        $this->assign('vo', $vo);

        //读取科目列表
        $subject = M('Subject');
        $vo1	 = $subject->select();
        $this->assign('subject', $vo1);

        //读取知识水平列表
        $knowledge      = M('knowledgepoint');
        $voknowledge    = $knowledge->where('(examid=0 and subjcetid='.$vo['subjectid'].') or examid='.$vo['subjectid'])->select();
        //dump(json_encode($vo));
        //trace('dd',$knowledge->getLastSql());
        $this->assign('knowledge',$voknowledge);

        //读取能力水平列表
        $ability      = M('abilitypoint');
        $voability    = $ability->where('(examid=0 and subjcetid='.$vo['subjectid'].') or examid='.$vo['subjectid'])->select();
        trace('dd',$ability->getLastSql());
        $this->assign('ability',$voability);

        //从vo[knowledgelist里读取出数据]
        $knlist     = explode(';',$vo['knowledgeList']);
        $knplist    = array();
        foreach ($knlist as $key => $value) {
            $knplist[$key]    = explode('#', $value);

        }
        
        $this->display();
    }

    //清除相应临时试卷成绩表的数据
    function clearTable(){
        $id         = I('id');//试卷ID
        $tableName  = 'score'.$id;
        $model      = new Model();
        $t = $model->execute("DROP TABLE IF EXISTS xspj_$tableName");
        echo '清除数据成功！';
    }
}
?>